package com.yc.vote.mapper;

import com.yc.vote.entity.TpItems;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 投票系统-题目选项表-9 Mapper 接口
 * </p>
 *
 * @author baomidou
 * @since 2023-07-10
 */
public interface TpItemsMapper extends BaseMapper<TpItems> {

    @Select("select a.*," +
            " (select count(*) from tp_record b where a.id=b.iid) nums" +
            " from tp_items a where vid=#{vid}")
    List<TpItems> selectByVid(String vid);

    @Insert("insert into tp_items values (default,#{iname},#{vid})")
    void insert(@Param("iname") String iname,
                @Param("vid") int vid);

}
